<script setup>
import { ref, onMounted } from 'vue'
import routes from '@/commons/router'
import Msg from '@/components/message'
import { useRoute } from 'vue-router'
import {showConfirmDialog} from "vant";

// 加载后调用监听滚动
onMounted(() => {
  checkInfo()
})

let examId
const stud = ref({ score: 0 })
const checkInfo = () => {
  examId = useRoute().params.examId
  stud.value = JSON.parse(localStorage.getItem('stud'))
  if(stud.value.realName==='') {
    Msg({ kind: 'error', txt: '没找到员工信息，请重新答题！' })
    routes.replace('/login/' + examId)
  }
  const score = stud.value.score.toFixed(3)
  stud.value.score = parseFloat(score)
}

const exits = () => {
  localStorage.removeItem('stud')
  routes.replace('/login/' + examId)
}

const toLog = () => {
  routes.replace('/log/' + stud.value.logId)
}

</script>

<template>
  <div class="res-a">
    <div class="res-b">露天煤矿风险辨识安全技能竞赛理论考试</div>
    <div class="res-c">恭喜您，交卷成功～！</div>
<!--    <div class="res-c">您的成绩为：<span class="res-d">{{ stud.score }}</span> <span class="res-e">分</span></div>-->
    <div class="res-f" @click="exits">安全退出</div>
<!--    <div class="res-f" @click="toLog">答题记录</div>-->
  </div>
</template>

<style>
.res-a {width: 100%; height: 100%; overflow: hidden;}
.res-b {padding: 5rem 0 0 2rem; font-size: 1.4rem; color: #009688; font-weight: bold; text-align: center;}
.res-c {padding: 2rem; text-align: center;}
.res-d {padding: 2rem 0; font-size: 1.5rem;}
.res-e {font-size: 0.9rem; color: #666;}
.res-f {padding: 0.8rem 0; margin-top: 2rem; color: #FFF; background-color: #2f73ff; border: 0; border-radius: 10px; cursor: pointer; text-align: center; font-size: 1.2rem;}
</style>